package com.youku.adSDK.view.components
{
   import flash.display.Sprite;
   import flash.display.SimpleButton;
   import flash.utils.Dictionary;
   import com.youku.adSDK.ADContext;
   import com.youku.adSDK.ADEventDispather;
   import com.youku.utils.AssetUtil;
   import com.youku.adSDK.model.vo.ADData;
   import com.youku.adSDK.view.events.ADPlayerEvent;
   import flash.events.MouseEvent;
   import com.youku.adSDK.view.events.VideoADEvent;
   import com.youku.adSDK.ADConstant;
   import com.youku.adSDK.YoukuAdEvent;
   import flash.events.Event;
   import com.youku.adSDK.Utils.AdOpenWindow;
   import flash.net.URLRequest;
   import flash.utils.setTimeout;
   import com.youku.adSDK.view.events.PaidLoaderEvent;
   import com.youku.adSDK.view.events.ADEvent;
   import com.youku.adSDK.Utils.AdTweener;
   import flash.external.ExternalInterface;
   import flash.net.sendToURL;
   
   public class VideoAD extends Sprite
   {
      
      public function VideoAD() {
         super();
         this._totalTime = 0;
         this._index = 0;
         this._loadIndex = 0;
         this._dataArr = [];
         this._playerArr = [];
         this._PIPDataArr = [];
         this._btnHide = false;
         this._volume = -1;
      }
      
      private var _totalTime:Number;
      
      private var _dataArr:Array;
      
      private var _index:int;
      
      private var _loadIndex:int;
      
      private var _PIPDataArr:Array;
      
      private var _back:Sprite;
      
      private var _player:ADPlayer;
      
      private var _playerArr:Array;
      
      private var _adBtn:SimpleButton;
      
      private var _counter:ADCountdown;
      
      private var _btnHide:Boolean;
      
      private var _sw:Number;
      
      private var _sh:Number;
      
      private var _screenMode:String;
      
      private var _barH:Number;
      
      private var _clickEnabled:Boolean = true;
      
      private var _volume:Number;
      
      private var _barHide:Boolean = false;
      
      private var _ADType:String;
      
      private var _isMute:Boolean = false;
      
      private var _tempVolumeChange:Boolean = false;
      
      private var _isPause:Boolean;
      
      private var _isShowPaid:Boolean;
      
      private var _paidLoader:PaidLoader;
      
      private var _isPaidLoaded:Boolean;
      
      private var _errorCount:int = 0;
      
      private var _isInfoBarShow:Boolean;
      
      private var _susDict:Dictionary;
      
      private var _context:ADContext;
      
      private var _eventDispather:ADEventDispather;
      
      private var _isFullScreen:Boolean;
      
      private var _isSkip:Boolean;
      
      private var _adType:String = "";
      
      private var _currentTime:Number = 0;
      
      public function init(param1:Array, param2:ADContext, param3:ADEventDispather, param4:Number, param5:Number, param6:Number) : void {
         this._dataArr = param1;
         this._context = param2;
         this._eventDispather = param3;
         this._sw = param4;
         this._sh = param5;
         this._barH = param6;
         this._isPause = false;
         this._isShowPaid = false;
         this._errorCount = 0;
         this._screenMode = this._context.screenMode;
         this._totalTime = this.getTotalTime();
         this.createItems();
         this.addEvents();
      }
      
      private function createItems() : void {
         this._back = new Sprite();
         this.addChild(this._back);
         this._adBtn = AssetUtil.getAsset("AD_btn") as SimpleButton;
         this._counter = new ADCountdown();
         this._counter.init();
         this._counter.hidePass();
         var _loc1_:Boolean = this._context.mute;
         _loc1_ = this._context.volume == 0;
         this._counter.setMute(_loc1_);
         this._adBtn.visible = false;
         this._counter.visible = false;
         this._paidLoader = new PaidLoader();
         this.createPlayer();
         this.layoutItems();
      }
      
      private function createPlayer() : void {
         var _loc2_:ADData = null;
         var _loc3_:ADPlayer = null;
         var _loc1_:* = 0;
         while(_loc1_ < this._playerArr.length)
         {
            this.removePlayer(_loc1_);
            _loc1_++;
         }
         this._playerArr = [];
         this._susDict = new Dictionary();
         _loc1_ = 0;
         while(_loc1_ < this._dataArr.length)
         {
            _loc2_ = this._dataArr[_loc1_] as ADData;
            if(_loc2_.RST == "video")
            {
               _loc3_ = new ADPlayer();
            }
            else if(_loc2_.RST == "swf")
            {
               _loc3_ = new SWFADPlayer();
               SWFADPlayer(_loc3_).videoTotalTime = this._context.totalTime;
            }
            
            _loc3_.addEventListener(ADPlayerEvent.META_DATA,this.onPlayerMetaData);
            _loc3_.addEventListener(ADPlayerEvent.PLAY_START,this.onPlayerPlayStart);
            _loc3_.addEventListener(ADPlayerEvent.LOAD_COMPLETE,this.onPlayerLoadComplete);
            _loc3_.addEventListener(ADPlayerEvent.ARRIVE_POINT,this.onPlayerArrivePoint);
            _loc3_.addEventListener(ADPlayerEvent.PLAY_OVER,this.onPlayerPlayOver);
            _loc3_.addEventListener(ADPlayerEvent.PLAY_STREAM_ERROR,this.onPlayerPlayError);
            _loc3_.addEventListener(ADPlayerEvent.PLAY_IO_ERROR,this.onPlayerPlayError);
            _loc3_.addEventListener(ADPlayerEvent.PLAY_SECURITY_ERROR,this.onPlayerPlayError);
            _loc3_.addEventListener(ADPlayerEvent.TIME_OUT,this.onPlayerPlayError);
            if(_loc2_.RST == "video")
            {
               _loc3_.addEventListener(MouseEvent.CLICK,this.onPlayerClick);
            }
            else if(_loc2_.RST == "swf")
            {
               _loc3_.addEventListener(ADPlayerEvent.SWF_CLICK,this.onPlayerClick);
            }
            
            _loc3_.buttonMode = true;
            _loc3_.id = _loc1_;
            _loc3_.init(_loc2_,this._sw,this._sh);
            if(this._volume != -1)
            {
               _loc3_.setVolume(this._volume);
            }
            this._playerArr.push(_loc3_);
            this._susDict[_loc2_] = false;
            _loc1_++;
         }
      }
      
      private function onPlayerMetaData(param1:ADPlayerEvent) : void {
         if(this._dataArr.length == 1 && !this._totalTime)
         {
            this._totalTime = param1.totalTime;
         }
      }
      
      private function onPlayerPlayStart(param1:ADPlayerEvent) : void {
         var _loc3_:ADData = null;
         this.dispatchEvent(new VideoADEvent(VideoADEvent.PLAY_START));
         if(!this._btnHide)
         {
            this._adBtn.visible = true;
            _loc3_ = this._dataArr[this._index] as ADData;
            if(_loc3_.RST == "swf")
            {
               this._adBtn.visible = false;
            }
            this._counter.visible = true;
            if(this._isShowPaid)
            {
               this._counter.showPass();
            }
            else
            {
               this._counter.hidePass();
            }
         }
         var _loc2_:ADData = this._dataArr[this._index] as ADData;
         this.sendSUS();
         this.callPIPStart();
      }
      
      private function onPlayerLoadComplete(param1:ADPlayerEvent) : void {
         if(this._loadIndex < this._dataArr.length - 1)
         {
            if(this._loadIndex < this._index)
            {
               this._loadIndex = this._index;
            }
            this._loadIndex = this._loadIndex + 1;
            if(this._loadIndex < this._playerArr.length)
            {
               ADPlayer(this._playerArr[this._loadIndex]).preload();
            }
         }
         else
         {
            this.dispatchEvent(new VideoADEvent(VideoADEvent.LOAD_COMPLETE));
         }
      }
      
      private function onPlayerArrivePoint(param1:ADPlayerEvent) : void {
         var _loc2_:String = param1.data as String;
         this.sendData([{"U":_loc2_}]);
      }
      
      private function onPlayerPlayOver(param1:ADPlayerEvent) : void {
         this.removePlayer(this._index);
         var _loc2_:ADData = this._dataArr[this._index] as ADData;
         this.sendData(_loc2_.SUE);
         this.playNextVideo();
      }
      
      private function onPlayerPlayError(param1:ADPlayerEvent) : void {
         var _loc2_:String = null;
         var _loc3_:* = 0;
         if(this._errorCount == 0)
         {
            _loc2_ = "";
            if(param1.type == ADPlayerEvent.PLAY_IO_ERROR)
            {
               _loc2_ = ADConstant.ERROR_CODE_IO;
            }
            else if(param1.type == ADPlayerEvent.PLAY_SECURITY_ERROR)
            {
               _loc2_ = ADConstant.ERROR_CODE_SECURITY;
            }
            else if(param1.type == ADPlayerEvent.TIME_OUT)
            {
               _loc2_ = ADConstant.ERROR_CODE_TIMEOUT;
            }
            else if(param1.type == ADPlayerEvent.PLAY_STREAM_ERROR)
            {
               _loc2_ = ADConstant.ERROR_CODE_STREAM;
            }
            
            
            
            this._eventDispather.dispatchEvent(new YoukuAdEvent(YoukuAdEvent.AD_LOAD_TIME,
               {
                  "isError":true,
                  "type":ADConstant.TYPE_AD,
                  "errorCode":_loc2_
               }));
         }
         this._errorCount++;
         if(param1.type == ADPlayerEvent.PLAY_IO_ERROR || param1.type == ADPlayerEvent.PLAY_SECURITY_ERROR || param1.type == ADPlayerEvent.PLAY_STREAM_ERROR)
         {
            _loc3_ = param1.id;
            if(_loc3_ == this._index)
            {
               this.removePlayer(this._index);
               this.playNextVideo();
            }
         }
         else if(param1.type == ADPlayerEvent.TIME_OUT)
         {
            this.removePlayer(this._index);
            this.playNextVideo();
         }
         
      }
      
      private function onPlayerClick(param1:Event) : void {
         if(!this._clickEnabled)
         {
            return;
         }
         var _loc2_:ADData = this._dataArr[this._index] as ADData;
         this.sendData(_loc2_.CUM);
         this.sendSUS();
         if(!(_loc2_.CU == null) && !(_loc2_.CU == ""))
         {
            AdOpenWindow.open(new URLRequest(String(_loc2_.CU)),"_blank");
         }
      }
      
      private function sendSUS() : void {
         var _loc1_:ADData = this._dataArr[this._index] as ADData;
         if(this._susDict[_loc1_] == false)
         {
            this.sendData(_loc1_.SUS);
            this._susDict[_loc1_] = true;
         }
      }
      
      private function playNextVideo(param1:Boolean = false) : void {
         var _loc2_:ADData = null;
         var _loc3_:ADPlayer = null;
         var _loc4_:VideoADEvent = null;
         if(!param1)
         {
            this._index = this._index + 1;
         }
         if(this._index < this._dataArr.length)
         {
            _loc2_ = this._dataArr[this._index] as ADData;
            _loc3_ = this._playerArr[this._index] as ADPlayer;
            if(Number(_loc2_.VT) == 1 || Number(_loc2_.VT) == 2)
            {
               setTimeout(this.sendVCCode,50 * (this._index + 1),String(_loc2_.VC));
            }
            if(Number(_loc2_.VT) == 2)
            {
               _loc4_ = new VideoADEvent(VideoADEvent.AD_VT);
               _loc4_.currentADTotalTime = int(_loc2_.AL);
               this.dispatchEvent(_loc4_);
               this.playNextVideo();
            }
            else if(_loc3_.isError == true)
            {
               this.playNextVideo();
            }
            else
            {
               this.playVideo(this._index);
               if(this._isPause)
               {
                  this.pause();
               }
            }
            
         }
         else
         {
            if(this._tempVolumeChange)
            {
               this._eventDispather.dispatchEvent(new YoukuAdEvent(YoukuAdEvent.AD_SOUND_MUTE,
                  {
                     "mute":false,
                     "volume":this._volume
                  }));
            }
            this.removeEventListener(Event.ENTER_FRAME,this.onThisEnterFrame);
            if(this._errorCount < this._dataArr.length)
            {
               this.dispatchEvent(new VideoADEvent(VideoADEvent.PLAY_OVER));
            }
            else
            {
               this.dispatchEvent(new VideoADEvent(VideoADEvent.PLAY_BLOCKED));
            }
         }
      }
      
      private function playVideo(param1:int) : void {
         if(param1 < 0 || param1 >= this._playerArr.length)
         {
            return;
         }
         var _loc2_:ADPlayer = this._playerArr[param1] as ADPlayer;
         _loc2_.setWH(this._sw,this._sh);
         if(this._isMute)
         {
            _loc2_.setVolume(0);
         }
         else
         {
            _loc2_.setVolume(this._volume);
         }
         addChild(_loc2_);
         addChild(this._adBtn);
         addChild(this._counter);
         this.layoutItems();
         _loc2_.play();
      }
      
      private function removePlayer(param1:int) : void {
         if(param1 < 0 || param1 >= this._playerArr.length)
         {
            return;
         }
         ADPlayer(this._playerArr[param1]).dispose();
         if(contains(this._playerArr[param1]))
         {
            removeChild(this._playerArr[param1]);
         }
      }
      
      private function addEvents() : void {
         this.addEventListener(Event.ENTER_FRAME,this.onThisEnterFrame);
         this._adBtn.addEventListener(MouseEvent.CLICK,this.onPlayerClick);
         this._counter.addEventListener(VideoADEvent.AD_MUTE,this.onADMute);
         this._counter.addEventListener(VideoADEvent.AD_PASS,this.onPaidButtonClick);
         this._paidLoader.addEventListener(PaidLoaderEvent.PAID_CLOSE_BUTTON_CLICK,this.onPaidLoaderEvent);
         this._paidLoader.addEventListener(PaidLoaderEvent.PAID_LOAD_FAIL,this.onPaidLoaderEvent);
         this._paidLoader.addEventListener(PaidLoaderEvent.PAID_LOAD_COMPLETE,this.onPaidLoaderEvent);
         this._eventDispather.addEventListener(ADEvent.CHANGE_SIZE,this.onPlayerResize);
         this._eventDispather.addEventListener(ADEvent.CHANGE_VOLUME,this.onPlayerChangeVolume);
         this._eventDispather.addEventListener(ADEvent.COMMON_RESET,this.onPlayerReset);
         this._eventDispather.addEventListener(ADEvent.CONTROL_BAR_HIDE,this.onBarHide);
         this._eventDispather.addEventListener(ADEvent.CONTROL_BAR_SHOW,this.onBarShow);
         this._eventDispather.addEventListener(ADEvent.CONTROL_BAR_INFO_BAR_SHOW,this.onInformationBarShow);
         this._eventDispather.addEventListener(ADEvent.CONTROL_BAR_INFO_BAR_HIDE,this.onInformationBarHide);
         this._eventDispather.addEventListener(ADEvent.CHANGE_SCREEN_MODE,this.onPlayerChangeMode);
      }
      
      private function onPaidLoaderEvent(param1:PaidLoaderEvent) : void {
         trace("onPaidLoaderEvent:",param1.type);
         switch(param1.type)
         {
            case PaidLoaderEvent.PAID_LOAD_COMPLETE:
               this.layoutPaidLoader();
               this._isPaidLoaded = true;
               addChild(this._paidLoader);
               break;
            case PaidLoaderEvent.PAID_LOAD_FAIL:
               this.resume();
               break;
            case PaidLoaderEvent.PAID_CLOSE_BUTTON_CLICK:
               this.resume();
               if(this.contains(this._paidLoader))
               {
                  this.removeChild(this._paidLoader);
               }
               break;
         }
      }
      
      private function layoutPaidLoader() : void {
         this._paidLoader.x = int((this._sw - this._paidLoader.width) / 2);
         this._paidLoader.y = int((this._sh - this._barH - this._paidLoader.height) / 2);
      }
      
      private function onPaidButtonClick(param1:Event) : void {
         var _loc2_:String = null;
         if(this._isSkip == true)
         {
            this.dispatchEvent(new VideoADEvent(VideoADEvent.AD_SKIP));
         }
         else
         {
            this.pause();
            if(this._isPaidLoaded)
            {
               this.layoutPaidLoader();
               addChild(this._paidLoader);
            }
            else
            {
               _loc2_ = String(Math.round(new Date().getTime() / (1000 * 60 * 60)));
               this._paidLoader.load("http://res.mfs.ykimg.com/05100000500779936714C0059F088996" + "?randoms=" + _loc2_);
            }
            this._eventDispather.dispatchEvent(new YoukuAdEvent(YoukuAdEvent.AD_VIDEO_PAID_SHOW,{"panel":"adPaid"}));
            this._eventDispather.dispatchEvent(new YoukuAdEvent(YoukuAdEvent.AD_USER_ACTION,"adsc"));
         }
      }
      
      private function onPlayerResize(param1:ADEvent) : void {
         this._sw = param1.data.width;
         this._sh = param1.data.height;
         this._barH = param1.data.cheight;
         this._isFullScreen = param1.data.fullscreen;
         this.layoutItems();
      }
      
      private function onPlayerChangeVolume(param1:ADEvent) : void {
         var _loc3_:ADPlayer = null;
         this._volume = param1.data.volume;
         var _loc2_:* = 0;
         while(_loc2_ < this._playerArr.length)
         {
            _loc3_ = this._playerArr[_loc2_] as ADPlayer;
            if(_loc3_)
            {
               _loc3_.setVolume(this._volume);
            }
            _loc2_++;
         }
         if(this._volume > 0)
         {
            this._counter.setMute(false);
            this._isMute = false;
         }
         else
         {
            this._counter.setMute(true);
            this._isMute = true;
         }
         this._tempVolumeChange = false;
      }
      
      private function onADMute(param1:VideoADEvent) : void {
         var _loc2_:* = NaN;
         var _loc4_:ADPlayer = null;
         this._isMute = param1.isMute;
         if(this._isMute)
         {
            _loc2_ = 0;
            this._eventDispather.dispatchEvent(new YoukuAdEvent(YoukuAdEvent.AD_USER_ACTION,"asmon"));
         }
         else
         {
            _loc2_ = this._volume;
            this._eventDispather.dispatchEvent(new YoukuAdEvent(YoukuAdEvent.AD_USER_ACTION,"asmoff"));
         }
         var _loc3_:* = 0;
         while(_loc3_ < this._playerArr.length)
         {
            _loc4_ = this._playerArr[_loc3_] as ADPlayer;
            if(_loc4_)
            {
               _loc4_.setVolume(_loc2_);
            }
            _loc3_++;
         }
         this._tempVolumeChange = true;
         this._eventDispather.dispatchEvent(new YoukuAdEvent(YoukuAdEvent.AD_SOUND_MUTE,
            {
               "mute":this._isMute,
               "volume":_loc2_
            }));
      }
      
      private function onBarHide(param1:ADEvent) : void {
         this._barHide = true;
         this.layoutItems();
      }
      
      private function onBarShow(param1:ADEvent) : void {
         this._barHide = false;
         this.layoutItems();
      }
      
      private function onInformationBarShow(param1:ADEvent) : void {
         this._isInfoBarShow = true;
         this.layoutItems();
      }
      
      private function onInformationBarHide(param1:ADEvent) : void {
         this._isInfoBarShow = false;
         this.layoutItems();
      }
      
      private function onThisEnterFrame(param1:Event) : void {
         var _loc8_:ADData = null;
         if(this._playerArr.length == 0 || this._index >= this._playerArr.length)
         {
            return;
         }
         var _loc2_:Number = 0;
         var _loc3_:* = 0;
         while(_loc3_ < this._index)
         {
            if(ADData(this._dataArr[_loc3_]).VT != 2)
            {
               _loc2_ = _loc2_ + ADPlayer(this._playerArr[_loc3_]).totalTime;
            }
            _loc3_++;
         }
         var _loc4_:ADPlayer = this._playerArr[this._index] as ADPlayer;
         if(_loc4_.totalTime - _loc4_.nowTime > -1)
         {
            _loc2_ = _loc2_ + _loc4_.nowTime;
         }
         this._currentTime = _loc2_;
         var _loc5_:Number = this._totalTime;
         var _loc6_:* = 0;
         while(_loc6_ < this._dataArr.length)
         {
            _loc8_ = this._dataArr[_loc6_] as ADData;
            if(_loc8_.VT == 2)
            {
               _loc5_ = _loc5_ - _loc8_.AL;
            }
            _loc6_++;
         }
         if(_loc5_ > 0 && _loc2_ >= 0 && (_loc4_.playStarted))
         {
            if(int(_loc5_ - _loc2_ + 1) > 0)
            {
               this._counter.showTime("" + int(_loc5_ - _loc2_ + 1));
            }
         }
         else
         {
            this._counter.showTime("");
         }
         var _loc7_:ADData = this._dataArr[this._index] as ADData;
         if(_loc7_.RST == "swf" && !(_loc7_.AL == 0) && _loc4_.totalTime - _loc4_.nowTime < 0)
         {
            if(this._counter.timeVisible == true)
            {
               this._counter.timeVisible = false;
            }
         }
         else if(this._counter.timeVisible == false)
         {
            this._counter.timeVisible = true;
         }
         
      }
      
      private function onPlayerReset(param1:ADEvent) : void {
         this.dispose();
      }
      
      private function onPlayerChangeMode(param1:ADEvent) : void {
         var _loc2_:ADPlayer = null;
         var _loc3_:* = NaN;
         var _loc4_:* = NaN;
         var _loc5_:* = NaN;
         this._screenMode = param1.data.mode;
         if((this._playerArr.length) && (param1.data.tween))
         {
            _loc2_ = this._playerArr[this._index] as ADPlayer;
            if(this._screenMode == "full")
            {
               _loc3_ = this._sw;
               _loc4_ = this._sh;
            }
            else
            {
               _loc5_ = Number(this._screenMode) / 100;
               _loc3_ = this._sw * _loc5_;
               _loc4_ = (this._sh - this._barH) * _loc5_;
            }
            AdTweener.to(_loc2_,0.5,
               {
                  "width":_loc3_,
                  "height":_loc4_,
                  "onUpdate":this.onScaleUpdate
               });
         }
         else
         {
            this.layoutItems();
         }
      }
      
      private function onScaleUpdate() : void {
         if(!this._playerArr.length)
         {
            return;
         }
         var _loc1_:ADPlayer = this._playerArr[this._index] as ADPlayer;
         var _loc2_:Number = _loc1_.width;
         var _loc3_:Number = _loc1_.height;
         _loc1_.x = (this._sw - _loc2_) / 2;
         _loc1_.y = (this._sh - this._barH - _loc3_) / 2;
      }
      
      private function drawBack() : void {
         this._back.graphics.clear();
         this._back.graphics.beginFill(0);
         this._back.graphics.drawRect(0,0,this._sw,this._sh);
         this._back.graphics.endFill();
      }
      
      private function layoutItems() : void {
         var _loc1_:* = NaN;
         var _loc2_:* = NaN;
         var _loc9_:* = NaN;
         var _loc10_:ADPlayer = null;
         if(this._screenMode == "full")
         {
            _loc1_ = this._sw;
            _loc2_ = this._sh;
         }
         else
         {
            _loc9_ = Number(this._screenMode) / 100;
            _loc1_ = this._sw * _loc9_;
            _loc2_ = (this._sh - this._barH) * _loc9_;
         }
         if((stage) && stage.displayState == "normal")
         {
            _loc1_ = this._sw;
            _loc2_ = this._sh - this._barH;
         }
         var _loc3_:* = 0;
         while(_loc3_ < this._playerArr.length)
         {
            _loc10_ = this._playerArr[_loc3_] as ADPlayer;
            _loc10_.setWH(_loc1_,_loc2_);
            if(_loc10_ is SWFADPlayer)
            {
               _loc10_.x = _loc10_.y = 0;
            }
            else
            {
               _loc10_.x = (this._sw - _loc10_.width) / 2;
               _loc10_.y = (this._sh - this._barH - _loc10_.height) / 2;
            }
            _loc3_++;
         }
         var _loc4_:Number = this._sw;
         var _loc5_:Number = this._sh;
         this._adBtn.x = _loc4_ - this._adBtn.width - 5;
         if(this._isShowPaid)
         {
            this._counter.showPass();
         }
         else
         {
            this._counter.hidePass();
         }
         this._counter.x = _loc4_ - this._counter.width;
         var _loc6_:Number = 0;
         var _loc7_:Number = this._barH;
         var _loc8_:Number = 0;
         if(this._isFullScreen)
         {
            if(this._barHide)
            {
               _loc7_ = 0;
            }
            else
            {
               _loc6_ = 34;
            }
            if(this._isInfoBarShow)
            {
               _loc8_ = 42;
            }
         }
         else if(this._isInfoBarShow)
         {
            _loc8_ = 28;
         }
         
         this._adBtn.y = _loc5_ - this._adBtn.height - _loc7_ - _loc8_ - 10;
         this._counter.y = _loc6_;
         this.drawBack();
         this.layoutPaidLoader();
      }
      
      private function callPIPStart() : void {
         try
         {
            if(this._ADType == ADConstant.INSERT_AD)
            {
               ExternalInterface.call("onPlayerMidAdInit",this._PIPDataArr,this._index);
            }
            else
            {
               ExternalInterface.call("onPlayerPreAdInit",this._PIPDataArr,this._index);
            }
         }
         catch(e:Error)
         {
         }
      }
      
      private function sendData(param1:Array) : void {
         var _loc3_:* = 0;
         var _loc4_:Object = null;
         var _loc5_:String = null;
         var _loc2_:ADData = this._dataArr[this._index] as ADData;
         if(_loc2_.RST == "swf")
         {
            return;
         }
         if((param1) && param1.length > 0)
         {
            _loc3_ = 0;
            while(_loc3_ < param1.length)
            {
               _loc4_ = param1[_loc3_] as Object;
               if((_loc4_) && (_loc4_.hasOwnProperty("U")))
               {
                  _loc5_ = param1[_loc3_].U as String;
                  if((_loc5_) && !(_loc5_.indexOf("http://") == -1))
                  {
                     sendToURL(new URLRequest(_loc5_));
                  }
               }
               _loc3_++;
            }
         }
      }
      
      public function play() : void {
         if(this._playerArr.length > 0)
         {
            this.playNextVideo(true);
         }
      }
      
      public function preload() : void {
         if(this._playerArr.length > 0)
         {
            ADPlayer(this._playerArr[this._index]).preload();
         }
      }
      
      public function hideBtns() : void {
         this._btnHide = true;
      }
      
      public function get totalTime() : Number {
         return this.getTotalTime();
      }
      
      private function getTotalTime() : Number {
         var _loc4_:ADData = null;
         var _loc1_:Number = 0;
         var _loc2_:int = this._dataArr.length;
         var _loc3_:* = 0;
         while(_loc3_ < _loc2_)
         {
            _loc4_ = this._dataArr[_loc3_] as ADData;
            if(_loc4_)
            {
               _loc1_ = _loc1_ + Number(_loc4_.AL);
            }
            _loc3_++;
         }
         return _loc1_;
      }
      
      private function sendVCCode(param1:String) : void {
         AdOpenWindow.open(new URLRequest(param1),"_self");
      }
      
      public function dispose() : void {
         var _loc1_:* = 0;
         while(_loc1_ < this._playerArr.length)
         {
            this.removePlayer(_loc1_);
            _loc1_++;
         }
         this._playerArr = [];
         if((this._adBtn) && (this._adBtn.parent))
         {
            this.removeChild(this._adBtn);
            this.removeChild(this._counter);
         }
         if(this.contains(this._back))
         {
            this._back.graphics.clear();
            this.removeChild(this._back);
         }
         this.removeEventListener(Event.ENTER_FRAME,this.onThisEnterFrame);
      }
      
      public function set clickEnabled(param1:Boolean) : void {
         this._clickEnabled = param1;
      }
      
      public function setVolume(param1:Number) : void {
         if(param1 >= 0)
         {
            this._volume = param1;
         }
      }
      
      public function set screenMode(param1:String) : void {
         this._screenMode = param1;
      }
      
      public function set ADType(param1:String) : void {
         this._ADType = param1;
      }
      
      public function set PIPDataArr(param1:Array) : void {
         this._PIPDataArr = param1;
      }
      
      public function pause() : void {
         this._isPause = true;
         var _loc1_:ADPlayer = ADPlayer(this._playerArr[this._index]);
         if(_loc1_)
         {
            _loc1_.pause();
         }
      }
      
      public function resume() : void {
         this._isPause = false;
         var _loc1_:ADPlayer = ADPlayer(this._playerArr[this._index]);
         if(_loc1_)
         {
            _loc1_.resume();
         }
      }
      
      public function showPaidButton() : void {
         this._isShowPaid = true;
         this.layoutItems();
      }
      
      public function hidePaidButton() : void {
         this._isShowPaid = false;
         this.layoutItems();
      }
      
      public function changePaidButton() : void {
         this._isSkip = true;
         this._counter.setPassText("关闭广告");
      }
      
      public function getCurrentTime() : Number {
         return this._currentTime;
      }
   }
}
